
/**
 * Module dependencies.
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var partials = require('express-partials');
var flash = require('connect-flash');

var app = express();

var MongoStore = require('connect-mongo')(express);
var settings = require('./settings');



// all environments
//std
app.set('port', process.env.PORT || 3000);
app.engine('.html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(partials());
app.use(flash());
app.use(express.bodyParser()); 
app.use(express.methodOverride()); 
app.use(express.cookieParser()); 
app.use(express.session({ 
secret: settings.cookieSecret, 
Store: new MongoStore({ 
db: settings.db 
}) 
})); 
app.use(app.router);
app.use(express.static(path.join(__dirname, 'static')));
//use route
routes(app);


//branch add
// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}


http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});

//trunk add
